=========================================================================== BBS: The Abacus * HST/DS * Potterville MI Date: 02-22-93 (23:04) Number: 55 From: WALT MAYO Refer#: NONE To: ALL Recvd: NO Subj: DOS SHELL Conf: (35) Quick Basi --------------------------------------------------------------------------- I don't know who wrote this, but I found it in a snippet file from this echo. It 's about 2 years old. Anyone who wants to put a SHELL TO DOS feature in their pr ogram will like this one. If DOES require modification if you use the standard Q B include file. Get rid of the RegType2 definition and the DECLARE for InteruptX . '===================================================================== 'Sample program to demonstrate DoShell SUBroutine, which uses 'CALL Interrupt from QB.LIB (QB.QLB). '===================================================================== DEFINT A-Z TYPE RegType2 AX AS INTEGER BX AS INTEGER CX AS INTEGER DX AS INTEGER BP AS INTEGER SI AS INTEGER DI AS INTEGER Flags AS INTEGER DS AS INTEGER ES AS INTEGER END TYPE 'You must link with QB.LIB (QB.QLB) to use Interrupt functions DECLARE SUB InterruptX (Intr%, InReg AS RegType2, OutReg AS RegType2) DECLARE SUB DoShell (Before$, Args$, After$) DoShell "Type EXIT to return", "", "Welcome back" 'Just to test it END '===================================================================== 'SUB DoShell(Before$,Args$,After$) 'Purpose: Use this routine rather than 'SHELL' and the original ' drive & directory will be restored when 'EXIT'ing the shell. ' Before$ = A reminder message to the user. Usually it will be ' something like "Type EXIT to return" ' After$ = A string message to the user upon reentry into the ' calling program. ' Args$ = Will be the null string "" for a plain vanilla SHELL. ' The SUB calls 'SHELL' as 'SHELL Args$' '====================================================================== SUB DoShell (Before$, Args$, After$) 'Declare some stuff to use DIM InReg AS RegType2 DIM OutReg AS RegType2 DIM CurrentDrive AS INTEGER DIM CurrentDir AS STRING * 64 'Get current disk drive InReg.AX = &H19 * 256 InterruptX &H21, InReg, OutReg CurrentDrive = OutReg.AX MOD 256 'Get current directory InReg.AX = &H47 * 256 InReg.DX = CurrentDrive + 1 'Note adding one to drive for this, or 'could use 0 for default drive InReg.DS = VARSEG(CurrentDir) InReg.SI = VARPTR(CurrentDir) InterruptX &H21, InReg, OutReg 'Do the shell IF Before$ <> "" THEN CLS : PRINT Before$ 'Optional SHELL Args$ IF After$ <> "" THEN CLS : PRINT After$ 'Optional 'Change to old disk drive InReg.AX = &HE * 256 InReg.DX = CurrentDrive InterruptX &H21, InReg, OutReg '(InReg.AX MOD 256 is the # of logical drives in the 'system if anyone is interested) 'Change to old subdirectory (Could use Int &H21 func &H3B instead) ToDir$ = CHR$(ASC("A") + CurrentDrive) + ":\" + LEFT$(CurrentDir, INSTR(Cur rentDir, CHR$(0))) CHDIR ToDir$ END SUB -----------------------> \\/alt --- GoldED 2.40 * Origin: Periscope! Home of the OPTOMETRY Echo! (1:3627/101) SEEN-BY: 1/211 11/2 4 13/13 101/1 108/89 109/25 110/69 114/5 123/19 124/1 SEEN-BY: 153/752 154/40 77 157/2 159/100 125 430 950 203/23 209/209 280/1 SEEN-BY: 390/1 396/1 15 397/2 2230/100 3603/20